<?php

namespace Modules\Admin\Http\Controllers\Categories;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Common\General\Security\Api\Gateway;
use Modules\Common\Models\AdminLog;
use Modules\Common\Models\Categories;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;


class Create
{
    /**
     *
     * @Route(path=/api/admin/category  method=post)
     */
    public function index()
    {
        $adminUserIdDefault = auth('api')->user()->id;
        $eidDefault = auth('api')->user()->eid; 
        $sidDefault = auth('api')->user()->sid; 

        $category = new Categories();
        $category->category_name = request('category_name');
        $category->parentid = request('parentid');
        $category->is_enabled = request('is_enabled');
        $category->admin_user_id = $adminUserIdDefault;
        $category->eid = $eidDefault;
        $category->sid = $sidDefault;
        $category->created_at = date('Y-m-d H:i:s');
        $category->save();
        return Api::success($category);
    }

}